package acm.test;

import java.util.Scanner;
public class Main3 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int a=0;
        int[] b=new int[n];
        while(true){
            String s=scanner.next();
            if(s.equals("add")){
                int val=scanner.nextInt();
                a++;
            }else if(s.equals("sync")){
                int val=scanner.nextInt();
                b[val]++;
            }else{
                int min=Integer.MAX_VALUE;
                for(int i=1;i<n;i++){
                    min=Math.min(min,b[i]);
                }
                System.out.println(min);
            }
        }
    }
}


